<template>
  <div>
    <el-input
      v-model="loginId"
      style="width: 240px"
      placeholder="请输入用户名"
    />
    <el-input
      v-model="password"
      style="width: 240px"
      placeholder="请输入密码"
    />
    <el-button type="primary" @click="login">登录</el-button>
  </div>
</template>
<script setup>
const loginId = ref("admin")
const password = ref("888888")
import userStore from "../store/index.js"
const { permissionList } = userStore()
import { useRoute, useRouter } from "vue-router"
// 得到 router 对象
const router = useRouter()
const login = () => {
  let admin = permissionList.adminList.find(
    (a) => a.loginId == loginId.value && a.password == password.value
  )
  if (admin) {
    // alert("登陆成功")
    router.push("/")
    // console.log(admin)
    permissionList.setCerrentAdmin(admin)
  } else {
    alert("请输入正确的账号密码")
  }
}
console.log(router.getRoutes())
</script>
<style scoped lang="less"></style>
